package com.qf.service.impl;

import com.qf.dao.Card1Dao;
import com.qf.dao.impl.Card1DaoImpl;
import com.qf.entity.Card1;
import com.qf.service.Card1Service;

import java.util.List;

public class Card1ServiceImpl implements Card1Service {
    private Card1Dao card1Dao = new Card1DaoImpl();
    @Override
    public List<Card1> findAllCard1(Integer uid) {
        List<Card1> allCard1 =card1Dao.findAllCard1(uid);
        return allCard1;
    }

    @Override
    public Card1 findOneCard1(Card1 card1) {
        return card1Dao.seleteOne(card1);
    }

    @Override
    public boolean add(Card1 card1) {
        if (card1Dao.add(card1)>=1){
            return true;
        }
        return false;
    }

    @Override
    public List<Card1> findByUid(String uid) {
        return card1Dao.selectByUid(uid);
    }

    @Override
    public boolean huodetixian(String id1, double money) {
        int a = card1Dao.shoukuan(id1,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public boolean jiaqian(String id1, double money) {
        int a = card1Dao.shoukuan(id1,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public boolean chongzhi(String id1, double money) {
        int a = card1Dao.zhifu(id1,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public boolean jianqian(String id1, double money) {
        int a = card1Dao.zhifu(id1,money);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public boolean editBalanceByID(double num, String c1) {
        int a = card1Dao.updateBalanceByID(num,c1);
        if (a >= 1){
            return true;
        }
        return false;
    }

    @Override
    public Card1 findByID(String id) {
        return card1Dao.selectOneById(id);
    }

    @Override
    public boolean yanzheng(String id1, String name, String phone, String password) {
        Card1 card1 = card1Dao.seleteOne(id1,name,phone,password);
        if (card1!=null){
            return true;
        }
        return false;
    }

    @Override
    public Card1 yanzheng(String id1, String name) {
        Card1 card1 = card1Dao.seleteOne(id1,name);
        if (card1!=null){
            return card1;
        }
        return null;
    }
}
